<template>
  <div>
    <div class="add-todo">
      <el-input v-model="value" />
      <el-button @click="addHandle"> 添加 </el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'

let emit = defineEmits(['addTodo'])
const value = ref('123')

const addHandle = () => {
  if (!value.value) {
    ElMessage.error('输入值不能为空')
    return
  }
  emit('addTodo', value.value)
}
</script>

<style scoped lang="less">
.add-todo {
  display: flex;
  .el-button {
    margin-left: 10px;
  }
}
</style>
